//: io/StoringAndRecoveringData.java
package io;
import java.io.*;

public class StoringAndRecoveringData {
  public static void main(String[] args)
  throws IOException {
    //包装输出流
    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(
            new FileOutputStream("E:\\Data.txt")));
    //写入数据
    out.writeDouble(3.14159);out.writeUTF("That was pi");
    out.writeDouble(1.41413);out.writeUTF("Square root of 2");
    out.close();
    //包装输入流
    DataInputStream in = new DataInputStream(new BufferedInputStream(
        new FileInputStream("E:\\Data.txt")));
    //读取数据
    System.out.println(in.readDouble());
    // Only readUTF() will recover the
    // Java-UTF String properly:System.out.println(in.readUTF());
    System.out.println(in.readDouble());System.out.println(in.readUTF());
  }
} /* Output:
3.14159
That was pi
1.41413
Square root of 2
*///:~
